/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 1.3</a>, using an XML
 * Schema.
 * $Id$
 */

package nl.biggrid.plier.opm;

import java.util.LinkedHashSet;

import nl.biggrid.plier.event.Event;
//import org.exolab.castor.jdo.TimeStampable;
import javax.jdo.annotations.PersistenceCapable;
/**
 * This class represents an OPM entity process (i.e an action or series of actions performed on or caused by artifacts,
and resulting in new artifacts).
 * 
 * @version $Revision$ $Date$
 */
@SuppressWarnings("serial")
@PersistenceCapable
public class Process implements java.io.Serializable {//, TimeStampable {


      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Field id.
     */
    private String id;

    /**
     * Field value.
     */
    private String value;

    /**
     * Field graph.
     */
    private OPMGraph graph;

    /**
     * Field _relatedAccountList.
     */
    private LinkedHashSet<Account> accounts;

    /**
     * Field _eventList.
     */
    private LinkedHashSet<Event> events;
    /**
     * Field timestamp for Castor to be able to update persistent OPMGraph objects.
     */
    //private long timestamp;

      //----------------/
     //- Constructors -/
    //----------------/
    /**
     * Class constructor.
     */
    public Process() {
        super();
        this.accounts = new LinkedHashSet<Account>();
        this.events = new LinkedHashSet<Event>();
    }

    public void addEvent(Event event) {
        events.add(event);
    }

      //-----------/
     //- Methods -/
    //-----------/

    /**
     * Sets the graph this process is part of.
     *
     * @param graph the graph to set from.
     */
    public void setGraph(OPMGraph graph) {
        this.graph = graph;
    }

    /**
     * Returns the graph this process is part of.
     *
     * @return the graph this process is part of.
     */
    public OPMGraph getGraph() {
        return graph;
    }

    /**
     * Returns the OPM ID of the process.
     *
     * @return the OPM ID of the process.
     */
    public java.lang.String getId(
    ) {
        return this.id;
    }

    /**
     * Returns the contents of the
     * collection in a Vector.
     *
     * @return this collection as a Vector
     */
    public LinkedHashSet<Account> getAccounts() {
        return this.accounts;
    }

    /**
     * Returns the contents of the
     * collection in a Vector.
     *
     * @return this collection as a Vector
     */
    public LinkedHashSet<Event> getEvents() {
        return this.events;
    }

    /**
     * Returns the OPM value of this process.
     *
     * @return the OPM value of this process.
     */
    public java.lang.String getValue(
    ) {
        return this.value;
    }

    /**
     * Sets the OPM ID of this process.
     *
     * @param id the value of the OPM ID.
     */
    public void setId(
            final java.lang.String id) {
        this.id = id;
    }


     /**
     * Sets the account list from a vector.
     *
     * @param vRelatedAccountArray The vector to set the account list from.
     */
    public void setAccounts(
            final LinkedHashSet<Account> vRelatedAccountArray) {
        //-- copy array
        this.accounts.clear();
        this.accounts = vRelatedAccountArray;
    }

     /**
     * Sets the event list from a vector.
     *
     * @param vEventVector The vector to set the event list from.
     */
    public void setEvents(
            final LinkedHashSet<Event> vEventVector) {
        //-- copy array
        this.events.clear();
        this.events = vEventVector;
    }

    /**
     * Sets the OPM value of this process.
     *
     * @param value the OPM value to set.
     */
    public void setValue(
            final java.lang.String value) {
        this.value = value;
    }


    /**
     * Adds an account to the list of accounts this agent belongs to.
     *
     * @param vRelatedAccount The account to add as an ID.
     * @throws java.lang.IndexOutOfBoundsException if the index
     * given is outside the bounds of the collection
     */
    public void addAccount(final Account anAccount) {
        this.accounts.add(anAccount);
    }

}